<?php

namespace App\Listeners;

//use Illuminate\Support\Facades\Redis;
use App\Events\UpdateStaffRoleEvent;

class ResetStaffRoleCache
{
    /**
     * 创建事件监听器
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * 处理事件
     *
     * @param  \App\Events\UpdateStaffRoleEvent  $event
     * @return void
     */
    public function handle(UpdateStaffRoleEvent $event)
    {
        if(!!$event->role){
            
            $staffs = $event->role->users;

            foreach($staffs as $staff){
                \Cache::forget(CACHE_PERMISSION_N.'.'.$staff->id);
            }                                    
        }
    }
}
